class_name HoldIceMagic
extends HoldMagic

@onready var marker_2d: Marker2D = $Marker2D
const PARTICLE_ICE_MAGIC = preload("uid://cevb5m3rgdl4d")


func use():
	var player = holder as Player
	player.level.emit_particle("particle_shoot_ice_magic", marker_2d.global_position)

	var magic = PARTICLE_ICE_MAGIC.instantiate() as ParticleIceMagic
	
	var config = item_data.item_config as MagicStaffConfig
	magic.attack = config.attack + player.player_data.get_attack()
	magic.critical_rate = config.critical_rate
	magic.critical_bonus = config.critical_bonus
	magic.knockback = config.knockback
	magic.sender = holder
	magic.level = player.level
	magic.hit_cam_shake_intensity = config.attack_cam_shake_intensity
	magic.hit_cam_shake_duration = config.attack_cam_shake_duration
	
	player.level.particles_parent.add_child(magic)
	magic.global_position = player.level.cross_hair.global_position
	magic.set_is_enemy(false)
